package com.benyanyi.image_grid_lib;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * @author mylove
 * @date 2021/9/30
 * @email ben@yanyi.red
 * @overview
 */
public class ImageDetailsFragment extends Fragment {

    private ImageView imageView;

    private String imgUrl;
    private int mDefaultRes = R.mipmap.benyanyi_image_default;//默认图片

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.benyanyi_frg_img, container, false);
        imageView = view.findViewById(R.id.img);
        if (getArguments() != null) {
            imgUrl = getArguments().getString("imgUrl", "");
        }
        GlideUtils.loadImg(imageView, imgUrl, 0);
        return view;
    }

    public static ImageDetailsFragment newInstance(String url) {
        Bundle args = new Bundle();
        args.putString("imgUrl", url);
        ImageDetailsFragment fragment = new ImageDetailsFragment();
        fragment.setArguments(args);
        return fragment;
    }
}
